package sku

import (
	"context"
	"mall/services/product/rpc/internal/mapper"

	"mall/services/product/rpc/internal/svc"
	"mall/services/product/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelSkuLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDelSkuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelSkuLogic {
	return &DelSkuLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DelSkuLogic) DelSku(in *pb.DelSkuDTO) (*pb.EmptyObj, error) {
	// del sku info
	skuMapper := mapper.NewSkuMapper()
	delErr := skuMapper.DelSkuForSkuIdCtx(l.ctx, l.svcCtx.DBEngin, in.SkuIdArr)
	if delErr != nil {
		return nil, delErr
	}
	return &pb.EmptyObj{}, nil
}
